n, nums = int(input()), list(map(str, input().split()))

for i in range(len(nums)):
    lowest = i
    for j in range(i + 1, len(nums)):
        if nums[j][len(nums[j]) - 1] < nums[lowest][len(nums[lowest]) - 1]:
            lowest = j
    nums[i], nums[lowest] = nums[lowest], nums[i]

print(" ".join(map(str, nums)))
